package com.aspose.cells;

import java.util.ArrayList;

class zajc {
   ArrayList a(zcfw var1) throws Exception {
      this.c(var1);
      if (var1.n()) {
         return null;
      } else {
         ArrayList var2 = new ArrayList();
         var1.d();

         while(true) {
            while(var1.r() != 4) {
               var1.j();
               if (var1.r() != 1) {
                  var1.a();
               } else if ("shape".equals(var1.p()) && !var1.n()) {
                  zou var3 = this.b(var1);
                  com.aspose.cells.b.a.a.ze.a(var2, (Object)var3);
               } else {
                  var1.a();
               }
            }

            return var2;
         }
      }
   }

   private zou b(zcfw var1) throws Exception {
      zou var2 = new zou();
      if (var1.m()) {
         while(true) {
            if (!var1.l()) {
               var1.k();
               break;
            }

            if ("id".equals(var1.p())) {
               var2.a(var1.s());
            } else if ("style".equals(var1.p())) {
               var2.b = var1.s();
            } else if ("preferrelative".equals(var1.p())) {
               boolean var3 = !"f".equals(var1.s());
               var2.d = var3;
            }
         }
      }

      var1.d();

      while(var1.r() != 4) {
         var1.j();
         if ("imagedata".equals(var1.p())) {
            this.a(var1, var2);
         } else if ("lock".equals(var1.p())) {
            String var4 = var1.a("aspectratio");
            var1.a();
            if (var4 != null) {
               var2.e = a(var4);
            }
         } else {
            var1.a();
         }
      }

      var1.h();
      return var2;
   }

   private void a(zcfw var1, zou var2) throws Exception {
      if (var1.m()) {
         while(true) {
            if (!var1.l()) {
               var1.k();
               break;
            }

            if ("relid".equals(var1.p())) {
               var2.a = var1.s();
            } else if ("title".equals(var1.p())) {
               var2.c = var1.s();
            } else if ("croptop".equals(var1.p())) {
               var2.h = b(var1.s());
            } else if ("cropbottom".equals(var1.p())) {
               var2.i = b(var1.s());
            } else if ("cropleft".equals(var1.p())) {
               var2.j = b(var1.s());
            } else if ("cropright".equals(var1.p())) {
               var2.k = b(var1.s());
            } else if ("blacklevel".equals(var1.p())) {
               var2.m = b(var1.s());
            } else if ("gain".equals(var1.p())) {
               var2.l = b(var1.s());
            } else if ("preferrelative".equals(var1.p())) {
               var2.d = a(var1.s());
            } else if ("grayscale".equals(var1.p())) {
               var2.f = a(var1.s());
            } else if ("bilevel".equals(var1.p())) {
               var2.g = a(var1.s());
            }
         }
      }

      var1.a();
   }

   static boolean a(String var0) {
      if (!"f".equals(var0) && !"false".equals(var0.toLowerCase())) {
         if (!"t".equals(var0) && !"true".equals(var0.toLowerCase())) {
            if ("1".equals(var0)) {
               return true;
            } else if ("0".equals(var0)) {
               return false;
            } else {
               throw new CellsException(6, "Error true/false format: " + var0);
            }
         } else {
            return true;
         }
      } else {
         return false;
      }
   }

   static double b(String var0) {
      double var1 = 0.0D;

      try {
         double var3;
         if (var0.endsWith("f")) {
            var0 = var0.substring(0, 0 + (var0.length() - 1));
            var3 = zase.B(var0);
            var1 = var3 / 65536.0D;
         } else if (var0.endsWith("%")) {
            var0 = var0.substring(0, 0 + (var0.length() - 1));
            var3 = zase.B(var0);
            var1 = var3 * 0.01D;
         } else {
            var1 = zase.B(var0);
         }
      } catch (Exception var5) {
         ;
      }

      return var1;
   }

   private void c(zcfw var1) throws Exception {
      var1.j();
      if (var1.r() != 1 || !"xml".equals(var1.p())) {
         throw new CellsException(6, "xml root element eror");
      }
   }
}
